package com.zhangxi.springbootwebzhangxi.service.impl;

import com.zhangxi.springbootwebzhangxi.dao.DeptMapper;
import com.zhangxi.springbootwebzhangxi.pojo.Dept;
import com.zhangxi.springbootwebzhangxi.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName: DeptServiceImpl
 * Package: com.zhangxi.springbootwebzhangxi.service.impl
 *///部门业务实现类
@Slf4j
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> allDept() {
        return deptMapper.allDept();
    }

    @Override
    public void deleteDept(Integer id) {
        deptMapper.deleteDept(id);
    }

    @Override
    public void insertDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insertDept(dept);
    }

    @Override
    public Dept getDept(Integer id) {
        return deptMapper.getDept(id);
    }

    @Override
    public void UpdateDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.UpdateDept(dept);
    }
}
